#include <bits/stdc++.h>

using i64 = long long;

constexpr int N = 5E5 + 10;

i64 a[N], b[N], tmp[N];

int n, m;
i64 t;

auto get(int l, int mid, int r) -> bool {
    int n = r - l;
    for (int i = mid; i < r; ++i) {
        b[i] = a[i];
    }
    std::sort(b + mid, b + r);

    int p = l, q = mid;
    for (int i = l; i < r; ++i) {
        if (p < mid && (q >= r || b[p] <= b[q])) {
            tmp[i] = b[p++];
        } else {
            tmp[i] = b[q++];
        }
    }

    i64 sum = 0;
    int cnt = std::min(n / 2, m);
    for (int i = 0; i < cnt; ++i) {
        auto x = tmp[n - i - 1 + l] - tmp[i + l];
        sum += x * x;
        if (sum > t) {
            return false;
        }
    }
    return true;
};


void solve() {
    std::cin >> n >> m >> t;

    for (int i = 0; i < n; ++i) {
        std::cin >> a[i];
    }

    int cnt = 0;
    int l = 0, r = 0;
    while (l < n) {
        int len = 1;
        while (len) {
            if (r + len <= n && get(l, r, r + len)) {
                r += len;
                for (int i = l; i < r; ++i) {
                    b[i] = tmp[i];
                }
                len <<= 1;
            } else {
                len >>= 1;
            }
        }
        ++cnt;
        l = r;
    }
    std::cout << cnt << "\n";
}

int main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);

    int t;
    std::cin >> t;

    while (t--) {
        solve();
    }

    return 0;
}